package list;
// Definition for singly-linked list.


public class ListNode {
    int val;
    ListNode next;
    ListNode() {}
    ListNode(int val) { this.val = val; }
    ListNode(int val, ListNode next) { this.val = val; this.next = next; }

    public static void main(String[] args) {

    }
}

class Solution {

    ListNode node=null;
    public ListNode removeElements(ListNode head, int val) {
        node=head;
        for(;node!=null;node=node.next){
            if(node.next.val==val){
                ListNode cur=node.next;
                node.next=cur.next;
            }
        }
    }
}

